/**
 * Copyright &copy; 2012-2016 <a href="https://www.kaaction.com">KAA</a> All rights reserved.
 */
package com.kaaction.modules.operate.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;

import com.kaaction.common.persistence.TreeEntity;

/**
 * 渠道Entity
 * @author zengbiao
 * @version 2017-04-12
 */
public class Channel extends TreeEntity<Channel> {
	
	private static final long serialVersionUID = 1L;
	private Channel parent;		// 父节点id
	private String parentIds;		// 祖先节点id
	private Integer sort;		// 排序值
	private String name;		// 名称
	private String website;		// 网址
	private String spreadLocation;		// 推广位置
	private String spreadPeriod;		// 推广周期
	private String spreadContent;		// 推广内容
	private Double spreadFee;		// 推广费用
	
	public Channel() {
		super();
	}

	public Channel(String id){
		super(id);
	}

	@JsonBackReference
	@NotNull(message="父节点id不能为空")
	public Channel getParent() {
		return parent;
	}

	public void setParent(Channel parent) {
		this.parent = parent;
	}
	
	@Length(min=1, max=2000, message="祖先节点id长度必须介于 1 和 2000 之间")
	public String getParentIds() {
		return parentIds;
	}

	public void setParentIds(String parentIds) {
		this.parentIds = parentIds;
	}
	
	@NotNull(message="排序值不能为空")
	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Length(min=0, max=64, message="网址长度必须介于 0 和 64 之间")
	public String getWebsite() {
		return website;
	}

	public void setWebsite(String website) {
		this.website = website;
	}
	
	@Length(min=0, max=64, message="推广位置长度必须介于 0 和 64 之间")
	public String getSpreadLocation() {
		return spreadLocation;
	}

	public void setSpreadLocation(String spreadLocation) {
		this.spreadLocation = spreadLocation;
	}
	
	@Length(min=0, max=64, message="推广周期长度必须介于 0 和 64 之间")
	public String getSpreadPeriod() {
		return spreadPeriod;
	}

	public void setSpreadPeriod(String spreadPeriod) {
		this.spreadPeriod = spreadPeriod;
	}
	
	public String getSpreadContent() {
		return spreadContent;
	}

	public void setSpreadContent(String spreadContent) {
		this.spreadContent = spreadContent;
	}
	
	public Double getSpreadFee() {
		return spreadFee;
	}

	public void setSpreadFee(Double spreadFee) {
		this.spreadFee = spreadFee;
	}
	
	public String getParentId() {
		return parent != null && parent.getId() != null ? parent.getId() : "0";
	}
}